﻿// JScript
    var tempObj;    
    var procode;//产品代码
// 初始化鼠标右键菜单
	function initPopmenu(){
        try
        {        
            procode=document.getElementById("hfProductServiceCode").value;    
		    var menuWidth = 150;
		    var menuHeight = 20;
		    popMenu = new PopMenu('../css/popmenu.css','menuNormal','menuHot','menuMain',menuWidth,menuHeight);

		    popMenu.addMenuItem("<img src='../icons/popmenu/1.gif'><span> 新增行&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><img src='../icons/popmenu/3.gif'>");
		    popMenu.addMenuItem("<img src='../icons/popmenu/1.gif'> 新增列&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img src='../icons/popmenu/3.gif'>");
		    popMenu.addMenuItem("");
		    popMenu.addMenuItem("<img src='../icons/popmenu/2.gif'> 移动整行到...","moveRow()");
		    popMenu.addMenuItem("<img src='../icons/popmenu/2.gif'> 移动单个到...","moveTo()");
		    popMenu.addMenuItem("");
		    //popMenu.addMenuItem("<img src='../icons/popmenu/delete.gif'> 删除","deleteRow()");
		    popMenu.addMenuItem("<img src='../icons/popmenu/refresh.gif'> 刷新","doRefresh()");
		    popMenu.addMenuItem("");
		    //alert(GetBrowser());
		    if(GetBrowser()=="IE7")
		    {
		        popMenu.addMenuItem("\n\r");
		        popMenu.addMenuItem("\n\r");
		        popMenu.addMenuItem("\n\r");
		    }
		    //popMenu.addMenuItem("<img src='/icons/popmenu/property.gif'> 属性","editProperty()");

		    var childMenu = popMenu.createChildMenu(0,menuWidth,menuHeight);
		    childMenu.addMenuItem("<img src='../icons/popmenu/text.gif'> 文本","newRow(0)");
		   // childMenu.addMenuItem("<img src='../icons/popmenu/next.gif'> 下级页面","newRow(1)");
		    childMenu.addMenuItem("<img src='../icons/popmenu/http.gif'> 自定义链接","newRow(2)");      
		    childMenu.addMenuItem("<img src='../icons/popmenu/logo.gif'> 图片","newRow(4)");	
		    childMenu.addMenuItem("<img src='../icons/popmenu/next.gif'> 资源栏目","newRow(19)");
		    childMenu.addMenuItem("<img src='../icons/popmenu/func.gif'> 视频资源","newRow(3)");
		    childMenu.addMenuItem("<img src='../icons/popmenu/next.gif'> 阅读资源","newRow(18)");		
		    childMenu.addMenuItem("<img src='../icons/popmenu/next.gif'> 游戏资源","newRow(20)");
		    childMenu.addMenuItem("<img src='../icons/popmenu/ring.gif'> 音乐资源","newRow(21)");
		    childMenu.addMenuItem("<img src='../icons/popmenu/next.gif'> 电商资源","newRow(22)");
		    childMenu.addMenuItem("<img src='../icons/popmenu/next.gif'> 动漫资源","newRow(23)");
		    childMenu.addMenuItem("<img src='../icons/popmenu/next.gif'> 短片资源","newRow(24)");
		    childMenu.addMenuItem("<img src='../icons/popmenu/next.gif'> 图片资源","newRow(25)");
		    var childMenu = popMenu.createChildMenu(1,menuWidth,menuHeight);
		    childMenu.addMenuItem("<img src='../icons/popmenu/text.gif'> 文本","newColumn(0)");
		  // childMenu.addMenuItem("<img src='../icons/popmenu/next.gif'> 下级页面","newColumn(1)");
		    childMenu.addMenuItem("<img src='../icons/popmenu/http.gif'> 自定义链接","newColumn(2)");
		    childMenu.addMenuItem("<img src='../icons/popmenu/logo.gif'> 图片","newColumn(4)");	 
		    childMenu.addMenuItem("<img src='../icons/popmenu/next.gif'> 资源栏目","newColumn(19)");	
		    childMenu.addMenuItem("<img src='../icons/popmenu/func.gif'> 视频资源","newColumn(3)");
		    childMenu.addMenuItem("<img src='../icons/popmenu/next.gif'> 阅读资源","newColumn(18)");		
		    childMenu.addMenuItem("<img src='../icons/popmenu/next.gif'> 游戏资源","newColumn(20)");	
		    childMenu.addMenuItem("<img src='../icons/popmenu/ring.gif'> 音乐资源","newColumn(21)");	
		    childMenu.addMenuItem("<img src='../icons/popmenu/next.gif'> 电商资源","newColumn(22)");		
		    childMenu.addMenuItem("<img src='../icons/popmenu/next.gif'> 动漫资源","newColumn(23)");	
		    childMenu.addMenuItem("<img src='../icons/popmenu/next.gif'> 短片资源","newColumn(24)");
		    childMenu.addMenuItem("<img src='../icons/popmenu/next.gif'> 图片资源","newColumn(25)");
        }
        catch(err)
        {
            //日志
            //ajaxFun.Log(document.getElementById("hfParentId").value,document.getElementById("hfElementId").value,"js:initPopmenu;"+err,document.getElementById("hfOldElementX").value,document.getElementById("hfOldElementY").value,document.getElementById("hfNewElementX").value,document.getElementById("hfNewElementY").value);
        }
	}	
	// 移动到指定行行内所有列都移动
	function moveRow()
	{
        try
        {
	        if(document.getElementById("hfElementId").value == "0" || document.getElementById("hfElementId").value == "")
	        {
	            alert("请行选择要执行操作的数据!");
	            return false;
	        }
	        //复原有过新增行的操作
            document.getElementById("ddlOldPositionX").value = document.getElementById("hfOldElementX").value;
            //控制移动新行的最大位置
	        var allRowNum=getRowNum();
            var objNewDdlX=document.getElementById("ddlNewPositionX");
            var maxNewX=objNewDdlX.options[objNewDdlX.options.length-1].value;
            if(maxNewX>allRowNum)
            {
                objNewDdlX.options.remove(objNewDdlX.options.length-1);
            }

	        document.getElementById("hfAction").value = "moveRow";
	        document.getElementById("divTargetPosition").style.display = "block";
	        document.getElementById("ddlNewPositionY").disabled="disabled";
	        document.getElementById("ddlNewPositionX").value=document.getElementById("hfNewElementX").value;
	        document.getElementById("ddlNewPositionX").focus();    	    
	        //IframeWidthHeightAuto();
	        //alert(objNewDdlX.options[objNewDdlX.options.length-1].value);
        }
        catch(err)
        {
            //日志
            ajaxFun.Log(document.getElementById("hfParentId").value,document.getElementById("hfElementId").value,"js:moveRow;"+err,document.getElementById("hfOldElementX").value,document.getElementById("hfOldElementY").value,document.getElementById("hfNewElementX").value,document.getElementById("hfNewElementY").value);
        }
	}
	// 移动到指定列  只移动选定元素
	function moveTo()
	{
        try
        {
	        if(document.getElementById("hfElementId").value == "0" || document.getElementById("hfElementId").value == "")
	        {
	            alert("请行选择要执行操作的数据!");
	            return false;
	        }
	        //复原有过新增行的操作
            document.getElementById("ddlOldPositionX").value = document.getElementById("hfOldElementX").value;
            document.getElementById("ddlOldPositionY").value = document.getElementById("hfOldElementY").value;
            //控制移动新行的最大位置
	        var allColNum=getColumnNum(document.getElementById("hfOldElementX").value);
            var objNewDdlX=document.getElementById("ddlNewPositionX");
            var maxNewX=objNewDdlX.options[objNewDdlX.options.length-1].value;
            //X坐标控制
	        if(allColNum<=1)
	        {
                if(maxNewX>getRowNum())
                {
                    objNewDdlX.options.remove(objNewDdlX.options.length-1);
                }
	        }
	        else
	        {
                if(maxNewX==getRowNum())
                {
                    var newMaxX=parseInt(maxNewX)+1;
                    var oOption=new Option(newMaxX,newMaxX);
                    objNewDdlX.options[objNewDdlX.length]=oOption;
                }
	        }
    	    
	        document.getElementById("hfAction").value = "moveColumn";
	        document.getElementById("divTargetPosition").style.display = "block";
	        document.getElementById("ddlNewPositionY").disabled="";
	        document.getElementById("ddlNewPositionX").value=document.getElementById("hfNewElementX").value;
	        //设置纵坐标的值
	        setDdlNewPositionY(document.getElementById("ddlNewPositionX").value);
	        document.getElementById("ddlNewPositionY").value=document.getElementById("hfNewElementY").value;
	        document.getElementById("ddlNewPositionX").focus();
    	    
	        //IframeWidthHeightAuto();

	        //alert(objNewDdlX.options[objNewDdlX.options.length-1].value);
        }
        catch(err)
        {
            //日志
            ajaxFun.Log(document.getElementById("hfParentId").value,document.getElementById("hfElementId").value,"js:moveTo;"+err,document.getElementById("hfOldElementX").value,document.getElementById("hfOldElementY").value,document.getElementById("hfNewElementX").value,document.getElementById("hfNewElementY").value);
        }
	}
	//设置新Y坐标下拉框的值
	function setDdlNewPositionY(newRowNumber)
	{
        try
        {
	        if(document.getElementById("hfAction").value == "moveColumn")
	        {
	            var allColNum=getColumnNum(newRowNumber);
	            //alert('此行总列数：'+allColNum);
	            //Y坐标控制
	            document.getElementById("hfNewElementY").value="1";
                var objNewDdlY=document.getElementById("ddlNewPositionY");
                var maxNewY=objNewDdlY.options[objNewDdlY.options.length-1].value;
	            //如果是同行移动，则Y坐标个数等于行元素数
	            if(newRowNumber==document.getElementById("hfOldElementX").value)
	            {
                    if(allColNum<parseInt(objNewDdlY.options(objNewDdlY.options.length-1).value))
                    {//多了减
	                    for(var i=8;i>allColNum;i--)
	                    {
	                        if(objNewDdlY.options.length>1)
                                objNewDdlY.options.remove(objNewDdlY.options.length-1);
	                    }
	                }
	                else
	                {//少了加
	                    for(var i=parseInt(maxNewY);i<allColNum;i++)
	                    {
                            if(i<8)
                            {
                                var newMaxY=i+1;
                                var oOption=new Option(newMaxY,newMaxY);
                                objNewDdlY.options[objNewDdlY.length]=oOption;
                            }
	                    }
	                }
	            }
	            else//异行移动
	            {
    	            var currentYvalue=parseInt(objNewDdlY.options(objNewDdlY.options.length-1).value);
                    if(allColNum<currentYvalue)
                    {//多了减
	                    for(var i=currentYvalue;i>allColNum+1;i--)
	                    {
	                        if(objNewDdlY.options.length>1)
                                objNewDdlY.options.remove(objNewDdlY.options.length-1);
	                    }
	                }
	                else
	                {//少了加
	                    for(var i=parseInt(maxNewY);i<allColNum+1;i++)
	                    {
                            if(i<8)
                            {
                                var newMaxY=i+1;
                                var oOption=new Option(newMaxY,newMaxY);
                                objNewDdlY.options[objNewDdlY.length]=oOption;
                            }
	                    }
	                }
                    objNewDdlY.value=objNewDdlY.options[objNewDdlY.options.length-1].value;
                    document.getElementById("hfNewElementY").value=objNewDdlY.value;
	            }
	        }
        }
        catch(err)
        {
            //日志
            ajaxFun.Log(document.getElementById("hfParentId").value,document.getElementById("hfElementId").value,"js:setDdlNewPositionY;"+err,document.getElementById("hfOldElementX").value,document.getElementById("hfOldElementY").value,document.getElementById("hfNewElementX").value,document.getElementById("hfNewElementY").value);
        }
	}
    
	// 选择列
    var oldSelectedGrid = null;
    var newSelectedGrid = null;
    //选择元素
    function EditGrid(elementId, parentId, elementType, rowNumber, columnNumber, title, content, icon, isShow, feeTime, sortCode, funid, objGrid)
    {
        try
        {
        	if(content==null)content='';
            document.getElementById("spanDdlOldPosition").style.display="none";
            document.getElementById("drag").innerHTML = "内容编辑";
            document.getElementById("hfAction").value = "edit";
            document.getElementById("hfElementId").value = elementId;
            document.getElementById("hfParentId").value = parentId;
            document.getElementById("hfElementType").value = elementType;
            document.getElementById("ddlOldPositionX").value = rowNumber;
            document.getElementById("ddlOldPositionY").value = columnNumber;
            document.getElementById("hfOldElementX").value = rowNumber;
            document.getElementById("hfOldElementY").value = columnNumber;
            document.getElementById("hfNewElementX").value = rowNumber;
            document.getElementById("hfNewElementY").value = columnNumber;
            document.getElementById("txtSource").value = title;
            document.getElementById("txtTitle").value = title;
            document.getElementById("txtContent").value = content;
            document.getElementById("hfContent").value = content;
            if(document.getElementById("ddlFeeTime")!=null)
            document.getElementById("ddlFeeTime").value = feeTime;
            document.getElementById("imgIcon").src = icon;//document.getElementById("hfIconReadPath").value + 
            document.getElementById("hfIcon").value = icon;
            document.getElementById("hfSortCode").value =sortCode;
            document.getElementById("hfFunID").value = funid;
            if(isShow==1)
                document.getElementById("cbIsShow").checked = true;
            else 
                document.getElementById("cbIsShow").checked = false;
                
            //组件content特殊处理
            if(elementType==5)
            {
                document.getElementById("txtContent").value="";
            }
            //推荐content特殊处理
            if(elementType==6)
            {
                document.getElementById("txtContent").value="";
            }
           
            //alert(elementType);
         
            showEditor(elementType);

            //改变背景色
            oldSelectedGrid = newSelectedGrid;
            newSelectedGrid = objGrid;
            if (oldSelectedGrid != null)
            {
                oldSelectedGrid.style.backgroundColor = "";
            }
            if (newSelectedGrid != null)
            {
                newSelectedGrid.style.backgroundColor = "#B9CBFF";
            }        
        }
        catch(err)
        {
        alert(err);
            //日志
            ajaxFun.Log(document.getElementById("hfParentId").value,document.getElementById("hfElementId").value,"js:EditGrid;"+err,document.getElementById("hfOldElementX").value,document.getElementById("hfOldElementY").value,document.getElementById("hfNewElementX").value,document.getElementById("hfNewElementY").value);
        }
    }

    // 新增行
    function newRow(elementType)
    {
        try
        {
            document.getElementById("spanDdlOldPosition").style.display="none";
            document.getElementById("drag").innerHTML = "内容添加";
            newElement(elementType);
            //新增定位到最新一行
            var objOldDdlX=document.getElementById("ddlOldPositionX");
            var maxOldX=objOldDdlX.options[objOldDdlX.options.length-1].value;
            var curRownum=getRowNum();
            if(curRownum>=maxOldX && curRownum>1)
            {
                var newMaxX=parseInt(curRownum)+1;
                var oOption=new Option(newMaxX,newMaxX);
                objOldDdlX.options[objOldDdlX.length]=oOption;
            }
            if(objOldDdlX.options.length>0)
                objOldDdlX.selectedIndex = objOldDdlX.options.length - 1;
            document.getElementById("ddlOldPositionY").selectedIndex = 0;
            document.getElementById("hfNewElementX").value=document.getElementById("ddlOldPositionX").value;
            document.getElementById("hfNewElementY").value=document.getElementById("ddlOldPositionY").value;
        }
        catch(err)
        {
            //日志
            ajaxFun.Log(document.getElementById("hfParentId").value,document.getElementById("hfElementId").value,"js:newRow;"+err,document.getElementById("hfOldElementX").value,document.getElementById("hfOldElementY").value,document.getElementById("hfNewElementX").value,document.getElementById("hfNewElementY").value);
        }
    }
    // 新增列
    function newColumn(elementType)
    {
        try
        {
            document.getElementById("drag").innerHTML = "内容添加";
	        if(document.getElementById("hfElementId").value == "0" || document.getElementById("hfElementId").value == "")
	        {
	            alert("请行选择元素!");
	            return false;
	        }
	        //判断目标位置是否为空
            //新增定位到当前列+1，如果当前已是第4列则定位到最新一行的第一列
            //选中元素后，点了新增行，再点新增列，应该将原行号复原
            document.getElementById("hfIsMaxRow").value="true";
            document.getElementById("ddlOldPositionX").value=document.getElementById("hfOldElementX").value;
	        var allColNum=getColumnNum(document.getElementById("hfOldElementX").value);
	        //alert(allColNum);
	        var newColNum=parseInt(document.getElementById("hfOldElementY").value)+1;
	        if(allColNum>=8)
	        {
	            //alert("目标列不为空!");
	            //return false;
	            document.getElementById("spanDdlOldPosition").style.display="";
	            //行加1，列为1
                document.getElementById("ddlOldPositionX").selectedIndex = document.getElementById("ddlOldPositionX").options.length - 1;
                document.getElementById("ddlOldPositionY").selectedIndex = 0;
	        }
	        else
	        {
                //行不变，列加1
                document.getElementById("ddlOldPositionY").value=newColNum;
	        }
            document.getElementById("hfNewElementX").value=document.getElementById("ddlOldPositionX").value;
            document.getElementById("hfNewElementY").value=document.getElementById("ddlOldPositionY").value;

            newElement(elementType);
        }
        catch(err)
        {
            //日志
            //ajaxFun.Log(document.getElementById("hfParentId").value,document.getElementById("hfElementId").value,"js:newColumn;"+err,document.getElementById("hfOldElementX").value,document.getElementById("hfOldElementY").value,document.getElementById("hfNewElementX").value,document.getElementById("hfNewElementY").value);
        }
    }
    //获得某行现有的列数
    function getColumnNum(rowNumber)
    {
        try
        {
            var rValue=0;
            var elementArrStr=document.getElementById("hfElementArray").value;
            var elementArr=elementArrStr.split("|");
            for(var i=0;i<elementArr.length;i++)
            {
                var rowArr=elementArr[i].split(",");
                if(rowArr[0]==rowNumber)
                rValue= parseInt(rowArr[1]);
            }
            return rValue;
        }
        catch(err)
        {
            //日志
           // ajaxFun.Log(document.getElementById("hfParentId").value,document.getElementById("hfElementId").value,"js:getColumnNum;"+err,document.getElementById("hfOldElementX").value,document.getElementById("hfOldElementY").value,document.getElementById("hfNewElementX").value,document.getElementById("hfNewElementY").value);
        }
    }
    //获得总行数
    function getRowNum()
    {
        try
        {
            var elementArrStr=document.getElementById("hfElementArray").value;
            var elementArr=elementArrStr.split("|");
            return parseInt(elementArr.length);
        }
        catch(err)
        {
            //日志
            ajaxFun.Log(document.getElementById("hfParentId").value,document.getElementById("hfElementId").value,"js:getRowNum;"+err,document.getElementById("hfOldElementX").value,document.getElementById("hfOldElementY").value,document.getElementById("hfNewElementX").value,document.getElementById("hfNewElementY").value);
        }
    }

    function newElement(elementType)
    {
        try
        {
            document.getElementById("hfAction").value="add";
            document.getElementById("hfElementType").value=elementType;
            clearEditor();
            showEditor(elementType);
        }
        catch(err)
        {
            //日志
            ajaxFun.Log(document.getElementById("hfParentId").value,document.getElementById("hfElementId").value,"js:newElement;"+err,document.getElementById("hfOldElementX").value,document.getElementById("hfOldElementY").value,document.getElementById("hfNewElementX").value,document.getElementById("hfNewElementY").value);
        }
    }
    function showEditor(elementType)
    {
        try
        {
            var objDivTargetPosition = document.getElementById("divTargetPosition");
            var objDivSource = document.getElementById("divSource");
            var objDivText = document.getElementById("divText");
            var objDivIcon = document.getElementById("divIcon");
            var objContent = document.getElementById("txtContent");

            var arrShow = new Array();
            switch(parseInt(elementType))
            {
                case 0:
                case 1:
                case 2:
                    arrShow = ["none", "none", "block", "none",""];
                    break;
                case 4:
                    arrShow = ["none", "none", "none", "block", ""];
                    break;
                case 3:
                case 5:
                case 6:
                case 7:
                case 8:
                case 9:
                case 10:
                case 16:
                case 11:
                case 12:
                case 13:
                case 17:
                case 15:
                case 14:
                case 18:
                case 19:
                case 20:
                case 21:
                case 22:
                case 23:
                case 24:
                case 25:
                    arrShow = ["none", "block", "block", "none", "disabled"];
                    break;
            }
            objDivTargetPosition.style.display = arrShow[0];
            objDivSource.style.display = arrShow[1];
            objDivText.style.display = arrShow[2];
            objDivIcon.style.display = arrShow[3];
            objContent.disabled = arrShow[4];
            
	        //IframeWidthHeightAuto();
            //绑定屏幕宽度
            InitScreenWidth();

        }
        catch(err)
        {
            //日志
            ajaxFun.Log(document.getElementById("hfParentId").value,document.getElementById("hfElementId").value,"js:showEditor;"+err,document.getElementById("hfOldElementX").value,document.getElementById("hfOldElementY").value,document.getElementById("hfNewElementX").value,document.getElementById("hfNewElementY").value);
        }
    }
    function clearEditor()
    {
        try
        {
            document.getElementById("txtSource").value="";
            document.getElementById("txtTitle").value = "";
            document.getElementById("txtContent").value = "";
            document.getElementById("hfContent").value = "";
            document.getElementById("imgIcon").src = "../images/blank.gif";
            document.getElementById("hfIcon").value = "";
        }
        catch(err)
        {
            //日志
            ajaxFun.Log(document.getElementById("hfParentId").value,document.getElementById("hfElementId").value,"js:clearEditor;"+err,document.getElementById("hfOldElementX").value,document.getElementById("hfOldElementY").value,document.getElementById("hfNewElementX").value,document.getElementById("hfNewElementY").value);
        }
    }
    
    function selectResource()
    {
        try
        {
            var elementType=parseInt(document.getElementById("hfElementType").value);
            var version=document.getElementById("hfVersion").value;
            var id=document.getElementById("hfParentId").value;
            var customer=document.getElementById("hfCustomer").value;
            var province=document.getElementById("hfProvince").value;
            //alert(customer+";"+province);
            returnValue=window.showModalDialog("resourcelist?Id="+id+"&elementType="+elementType+"&version="+version+"&customername="+customer+"&province="+province+"","source", "resizable:yes;status:yes;dialogWidth:1000px;dialogHeight:600px;");
            if(returnValue!=null)
            {
                //alert(returnValue);
                var arrStr=returnValue.split("|");
                var idStr=arrStr[0];
                var titleStr=arrStr[1];
                var iconUrl;
                var linkPre="";
                var sortid;
                document.getElementById("txtSource").value=titleStr;
                document.getElementById("txtTitle").value=titleStr;
                switch(elementType)
                {
                    case 0://文本
                    case 1://页面
                    case 2://自定义链接
	                    document.getElementById("txtContent").disabled="";
                        break;
                    case 3://视频
                    	document.getElementById("txtContent").disabled="disabled";
	                    sortid=arrStr[2];
                        document.getElementById("txtContent").value = arrStr[0];
                        document.getElementById("hfContent").value = arrStr[0];
                        document.getElementById("hfFunID").value=arrStr[4];
                        document.getElementById("hfSortCode").value = sortid; 
                        break;
                    case 18://小说	                 
                    	 document.getElementById("txtContent").disabled="disabled";
 	                     sortid=arrStr[2];
                         document.getElementById("txtContent").value = arrStr[0];
                         document.getElementById("hfContent").value = arrStr[0];
                         document.getElementById("hfFunID").value=arrStr[4];
                         document.getElementById("hfSortCode").value = sortid;                        
                    	break;
                    case 20://游戏	                 
                   	 document.getElementById("txtContent").disabled="disabled";
	                     sortid=arrStr[2];
                        document.getElementById("txtContent").value = arrStr[0];
                        document.getElementById("hfContent").value = arrStr[0];
                        document.getElementById("hfFunID").value=arrStr[4];
                        document.getElementById("hfSortCode").value = sortid;                        
                   	break;
                    case 21://音乐	                 
                   	 document.getElementById("txtContent").disabled="disabled";
	                     sortid=arrStr[2];
                        document.getElementById("txtContent").value = arrStr[0];
                        document.getElementById("hfContent").value = arrStr[0];
                        document.getElementById("hfFunID").value=arrStr[4];
                        document.getElementById("hfSortCode").value = sortid;                        
                   	break;
                    case 22://购物	                 
                   	 document.getElementById("txtContent").disabled="disabled";
	                     sortid=arrStr[2];
                        document.getElementById("txtContent").value = arrStr[0];
                        document.getElementById("hfContent").value = arrStr[0];
                        document.getElementById("hfFunID").value=arrStr[4];
                        document.getElementById("hfSortCode").value = sortid;                        
                   	break;
                    case 23://动漫	                 
                      	 document.getElementById("txtContent").disabled="disabled";
   	                     sortid=arrStr[2];
                           document.getElementById("txtContent").value = arrStr[0];
                           document.getElementById("hfContent").value = arrStr[0];
                           document.getElementById("hfFunID").value=arrStr[4];
                           document.getElementById("hfSortCode").value = sortid;                        
                      	break;
                    case 24://短片	                 
                      	 document.getElementById("txtContent").disabled="disabled";
   	                     sortid=arrStr[2];
                           document.getElementById("txtContent").value = arrStr[0];
                           document.getElementById("hfContent").value = arrStr[0];
                           document.getElementById("hfFunID").value=arrStr[4];
                           document.getElementById("hfSortCode").value = sortid;                        
                      	break;    
                    case 25://图片资源	                 
                     	 document.getElementById("txtContent").disabled="disabled";
  	                     sortid=arrStr[2];
                          document.getElementById("txtContent").value = arrStr[0];
                          document.getElementById("hfContent").value = arrStr[0];
                          document.getElementById("hfFunID").value=arrStr[4];
                          document.getElementById("hfSortCode").value = sortid;                        
                     	break; 
                    case 19://资源栏目	                 
                   	 document.getElementById("txtContent").disabled="disabled";
	                     sortid=arrStr[2];
                        document.getElementById("txtContent").value = arrStr[0];
                        document.getElementById("hfContent").value = arrStr[0];
                        document.getElementById("hfFunID").value=arrStr[4];
                        document.getElementById("hfSortCode").value = sortid;                        
                   	break;
                    case 4://图标                    	
	                    iconUrl=arrStr[2];
	                    sortid=arrStr[3];
	                    document.getElementById("imgIcon").src=iconUrl;
	                    document.getElementById("hfIcon").value=iconUrl;
	                    document.getElementById("hfFunID").value=sortid;
	                    var iconHeight=document.getElementById("imgIcon").Height;
	                    var fieldsetedit=document.getElementById("editFieldset");
	                    var curHeight=parseInt(fieldsetedit.style.Height)+parseInt(iconHeight);
	                    fieldsetedit.style.Height=curHeight;
                        break;                    
                }
            }
	        //IframeWidthHeightAuto();
        }
        catch(err)
        {
            //日志
           // ajaxFun.Log(document.getElementById("hfParentId").value,document.getElementById("hfElementId").value,"js:selectResource;"+err,document.getElementById("hfOldElementX").value,document.getElementById("hfOldElementY").value,document.getElementById("hfNewElementX").value,document.getElementById("hfNewElementY").value);
        }
    }
    function clearResource()
    {
        try
        {
            document.getElementById("txtTitle").value = "";
            document.getElementById("txtSource").value="";
            document.getElementById("txtContent").value = "";
            document.getElementById("hfContent").value = "";
        }
        catch(err)
        {
            //日志
            //ajaxFun.Log(document.getElementById("hfParentId").value,document.getElementById("hfElementId").value,"js:clearResource;"+err,document.getElementById("hfOldElementX").value,document.getElementById("hfOldElementY").value,document.getElementById("hfNewElementX").value,document.getElementById("hfNewElementY").value);
        }
    }
    function clearIcon()
    {
        try
        {
            document.getElementById("imgIcon").src = "../images/blank.gif";
            document.getElementById("hfIcon").value = "";
        }
        catch(err)
        {
            //日志
            ajaxFun.Log(document.getElementById("hfParentId").value,document.getElementById("hfElementId").value,"js:clearIcon;"+err,document.getElementById("hfOldElementX").value,document.getElementById("hfOldElementY").value,document.getElementById("hfNewElementX").value,document.getElementById("hfNewElementY").value);
        }
    }
    
    function deleteRow()
    {
      if(window.confirm("确定要删除？"))
      {

      }
      else
      {

      }
    }
    
    function doRefresh()
    {
        window.location.reload();
    }
    
    function getSelectedValue(objSelect)
    {
        for (var i = 0; i < objSelect.options.length; i++)
        {
            if (objSelect.options[i].selected)
            {
                return objSelect.options[i].value;
            }
        }
    }
    
    function setSelectedValue(objSelect, selectedValue)
    {
        for (var i = 0; i < objSelect.options.length; i++)
        {
            if (objSelect.options[i].value == selectedValue.toString())
            {
                objSelect.options[i].selected = true;
            }
        }
    }
    
    //框架宽度高度自动伸展
   function IframeWidthHeightAuto()
    {
        try
        {
            if(parent.document.all("editIframe")!=null)
            {
                parent.document.all("editIframe").style.height=document.body.scrollHeight;
                parent.document.all("editIframe").style.width=document.body.scrollWidth;
            }
        }
        catch(err)
        {
            //日志
            ajaxFun.Log(document.getElementById("hfParentId").value,document.getElementById("hfElementId").value,"js:IframeWidthHeightAuto;"+err,document.getElementById("hfOldElementX").value,document.getElementById("hfOldElementY").value,document.getElementById("hfNewElementX").value,document.getElementById("hfNewElementY").value);
        }
    }
    
    function elementOnmouseover(obj,elementId,onFlag)
    {
        var hfElementId=parseInt(document.getElementById('hfElementId').value);
        if(onFlag)
        {
            if(hfElementId=="0" || hfElementId!=elementId)
            {
                obj.style.backgroundColor='#FFFF00';
            }
        }
        else
        {
            if(hfElementId=="0" || hfElementId!=elementId)
            {
                obj.style.backgroundColor='';
            }
        }
    }

    function deleteCheck()
    {
        try
        {
            if(document.getElementById('hfElementId').value!="0")
            {
                if(window.confirm("确定删除？"))
                {
                    return true;
                }
                else return false;
            }
            else
            {
                alert('请选择元素！');
                return false;
            }
        }
        catch(err)
        {
            //日志
            ajaxFun.Log(document.getElementById("hfParentId").value,document.getElementById("hfElementId").value,"js:deleteCheck;"+err,document.getElementById("hfOldElementX").value,document.getElementById("hfOldElementY").value,document.getElementById("hfNewElementX").value,document.getElementById("hfNewElementY").value);
        }
    }
    //提交前数据查看
    function submitDataCheck()
    {
        try
        {        
          //alert('动作：'+document.getElementById("hfAction").value+'旧X：'+document.getElementById("hfOldElementX").value+"旧Y："+document.getElementById("hfOldElementY").value+'新X：'+document.getElementById("hfNewElementX").value+"新Y："+document.getElementById("hfNewElementY").value);
          if(window.confirm("确定执行此操作？"))
          {
            //return true;
          }
          else 
          {
        	  window.event.returnValue = false;
        	  return ;
          }
         
          var rValue=false;
          
          switch(document.getElementById("hfElementType").value)
          {
            // case "12":   rValue=true;break;
              case "0":
              case "1":
              case "2":
              if(document.getElementById("txtTitle").value.replace(/\s/g, "")!="")
              {
                  if(CheckXML(document.getElementById("txtTitle").value))
                      rValue=true;
                  else
                  {
                      alert('含有非法字符！');
                      window.event.returnValue = false;
                	  return ;
                  }
              }
              else
              {
                  alert('请输入文本！');
                  window.event.returnValue = false;
            	  return ;
              }
              break;
              case "6":
              if(document.getElementById("hfContent").value!="")
              {
                  if(CheckXML(document.getElementById("hfContent").value))
                      rValue=true;
                  else
                  {
                      alert('含有非法字符！');
                      window.event.returnValue = false;
                	  return ;
                  }
              }
              else
              {
                  alert('请选择资源！');
                  window.event.returnValue = false;
            	  return ;
              }
              break;
              case "3":
              case "7":
              case "8":
              case "9":
              case "10":
              case "11":
              case "12":
              case "13":
              case "14":
              case "15":
              case "16":
              case "17":
              case "18":
              case "19":
              case "20":
              case "21":
              case "22":
              case "23":
              case "24":
              case "25":
              if(Trim(document.getElementById("txtTitle").value)!="")
              {
            	  var tt=Trim(document.getElementById("txtTitle").value);
            	  if(tt.indexOf("@")>0)
            	  {
            		  var titlts=tt.split("@");
            		  if(titlts[0].length>12||titlts[1].length>12)
        			  {
	            		  alert('资源名称不能超过12个字！');
	            		  document.getElementById("txtTitle").focus();
	                      window.event.returnValue = false;
	                      return ;
        			  }
            	  }
            	  else
            	  {
            		  	if(tt.length>12)
            			  {
		            		  alert('资源名称不能超过12个字！');
		            		  document.getElementById("txtTitle").focus();
		                      window.event.returnValue = false;
		                      return ;
            			  }
            	  }
                  if(document.getElementById("txtContent").value!="")
                  {
                      rValue=true;
//                      if(CheckXML(document.getElementById("txtContent").value))
//                          rValue=true;
//                      else
//                      {
//                          alert('含有非法字符！');
//                          rValue=false;
//                      }
                  }
                  else
                  {
                      alert('请选择资源！');
                      window.event.returnValue = false;
                      return ;
                  }
              }
              else
              {
                  alert('请输入文本！');
                  document.getElementById("txtTitle").focus();
                  window.event.returnValue = false;
                  return ;
              }
              break;
              case "4":
              if(document.getElementById("hfIcon").value!="")
                  rValue=true;
              else
              {
                  alert('请选择图标资源！');
                  window.event.returnValue = false;
                  return ;
              }
              break;
              case "5":
              if(document.getElementById("hfContent").value!="")
              {
                  rValue=true;
//                  if(CheckXML(document.getElementById("hfContent").value))
//                      rValue=true;
//                  else
//                  {
//                      alert('含有非法字符！');
//                      window.event.returnValue = false;
//                  }
              }
              else
              {
                  alert('请选择组件资源！');
                  window.event.returnValue = false;
                  return ;
              }
              break;
          }
          if(rValue&&document.getElementById("hfElementType").value!='12')//
          {
          
              var pattern=/^\d+$/;
              if(pattern.test(document.getElementById("ddlFeeTime").value))
                  rValue=true;
              else
              {
                  alert('计费次数填写错误，请输入非负整数！');
                  window.event.returnValue = false;
                  return ;
              }
          }
          return rValue;
        }
        catch(err)
        {
            //日志
            ajaxFun.Log(document.getElementById("hfParentId").value,document.getElementById("hfElementId").value,"js:submitDataCheck;"+err,document.getElementById("hfOldElementX").value,document.getElementById("hfOldElementY").value,document.getElementById("hfNewElementX").value,document.getElementById("hfNewElementY").value);
        }
    }
    
    function GetBrowser()
    {
        var rValue="";
        var browser=navigator.appName;
        var b_version=navigator.appVersion;
        var version=b_version.split(";"); 
        var trim_Version=version[1].replace(/[ ]/g,""); 
        //alert(trim_Version);
        if(browser=="Microsoft Internet Explorer" && trim_Version=="MSIE7.0") 
        { 
            rValue="IE7"; 
        } 
        else if(browser=="Microsoft Internet Explorer" && trim_Version=="MSIE6.0") 
        { 
            rValue="IE6"; 
        } 

       return rValue;
    }
    
    function Trim(str)
    {
        str=str.replace(/(^\s*)|(\s*$)/g, ""); 
        return str;
    }
    function CheckXML(str)
    {
        var rValue=false;
//        var pattern=/(<)|(&)|(')|(")|(>)|(;)|(%)/;  
        var pattern="";// /[<>&'";%*?:|/\\]/; 
        if(pattern.test(str))
            rValue= false;
        else rValue= true;
        if(rValue && CheckSQL(str))
        {
            rValue= true;
        }
        else rValue= false;
        return rValue;
    }
    function CheckSQL(str)
    {
        var rValue=false;
        var pattern=/(\sand\s)|(\slike\s)|(select\s)|(insert\s)|(delete\s)|(update\s[\s\S].*\sset)|(create\s)|(print\s)|(exec\s)|(declare)|(\struncate)|(\smaster)|(\sbackup)|(\smid)|(\scount)|(cast)|(%)|(\sadd\s)|(\salter\s)|(\sdrop\s)|(\sfrom\s)|(\struncate\s)|(\sxp_cmdshell\s)|(execute\s)|(\sin)|(\sset\s)|(\sor\s)/;  
        str=str.toLowerCase();
        if(pattern.test(str))
        {
            rValue= false;
        }
        else rValue= true;

        return rValue;
    }
    function XMLEncode(str)
    {
		str=Trim(str);
		str=str.replace(/\r\n/g," ");
		str=str.replace(/&/g,"&amp;");
		str=str.replace(/</g,"&lt;");
		str=str.replace(/>/g,"&gt;");
		str=str.replace(/'/g,"&apos;");
		str=str.replace(/""/g,"&quot;");
		return str;
	}
    function InitScreenWidth()
    {
        try
        {
        	document.getElementById("ddlScreenWidth").value=4;
            //document.getElementById("ddlScreenWidth").value=ajaxFun.WapEditorGetScreenWidth().value;
            //alert(ajaxFun.WapEditorGetScreenWidth().value);
        }
        catch(ex)
        {
	        alert(ex+'，InitScreenWidth出现错误，请重新操作！');
	        window.location.href=window.location;
            //日志
            //ajaxFun.Log(document.getElementById("hfPartnerId").value,document.getElementById("hfParentId").value,document.getElementById("hfElementId").value,"js:ChangeScreenWidth;"+err,document.getElementById("hfOldElementX").value,document.getElementById("hfOldElementY").value,document.getElementById("hfNewElementX").value,document.getElementById("hfNewElementY").value);
        }
    }
	